Skip to content

RB_GC_GUARD() the VALUE for RSTRING_PTR() to ensure the char* does not move#3892

Merged
kddnewton merged 2 commits into
ruby:mainfrom
eregon:ensure-RUBY_VERSION-does-not-move
Feb 3, 2026
Merged

RB_GC_GUARD() the VALUE for RSTRING_PTR() to ensure the char* does not move#3892
kddnewton merged 2 commits into
ruby:mainfrom
eregon:ensure-RUBY_VERSION-does-not-move

Conversation

@eregon

@eregon eregon commented Jan 29, 2026

Copy link
Copy Markdown
Member

When I initially wrote this, I used `RUBY_VERSION` so it's easier to stub in tests
But turns out that doesn't work in CRuby tests

@Earlopain Earlopain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I simplified this a bit. Does this make sense to you? Initially I used RUBY_VERSION so it's possible to stub in tests but that didn't work out in CRuby tests so it doesn't really make sesne to keep around just for that.

@kddnewton kddnewton left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this approach!

@kddnewton
kddnewton merged commit 7caa659 into ruby:main Feb 3, 2026
66 checks passed
@eregon

eregon commented Feb 3, 2026

Copy link
Copy Markdown
Member Author

@Earlopain Nice, I was thinking indeed there is probably a more direct way to access the value.

This is using https://github.com/ruby/ruby/blob/3237be163c313af0b6626b209e55bdb0b33c9f0f/include/ruby/version.h#L107-L113 for reference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants